feat(sdk-coin-polyx): add v8 staking builders#9164
Conversation
Polymesh v8 changed staking.bond from bond(controller, value, payee) to
bond(value, payee) — the stash is its own controller. Add V8BatchStakingBuilder
that builds utility.batchAll([bond, nominate]) with the 2-arg v8 bond against
v8 chain metadata, plus thin v8 metadata wrappers for bondExtra, unbond, batch
unstaking, withdrawUnbonded, and nominate (logic unchanged, v8 material only).
The v7 BatchStakingBuilder and sibling builders are retained as the Flipt
rollback path and marked [CLEANUP-V8-OLD]. The factory exposes getV8* methods
and from() now routes v8-encoded staking transactions (which cannot be decoded
with v7 material) to the matching v8 builder.
Verified the built batchAll method hex is byte-for-byte identical to the
testnet sandbox tx (block 24829135) and decodes to bond({ value, payee }) with
no controller at specVersion 8000000.
Ticket: SI-915
9e6697c to
da400f4
Compare
|
@claude review this PR |
|
Claude finished @abhijit0943's task —— View job PR Review: v8 Staking Builders for PolymeshI've completed my review of this PR which adds v8 staking builders for Polymesh. Overall, this is a well-structured and thoroughly implemented change that properly handles the v7→v8 migration. Here are my findings: ✅ Strengths
🔍 Technical Review PointsV8BatchStakingBuilder.ts:67-74 - The type assertion here is somewhat awkward: const bondCall = methods.staking.bond(
{
value: this._amount,
payee: this._payee || 'Staked',
} as unknown as { controller: string; value: string; payee: string | { Account: string } },
baseTxInfo.baseTxInfo,
baseTxInfo.options
);This works but suggests the underlying Factory Integration (transactionBuilderFactory.ts:178-184) - The v8 fallback logic is well-implemented. The approach of catching v7 decode errors and retrying with v8 material is pragmatic and handles the migration cleanly. Test Quality - The tests are particularly strong. I especially appreciate:
📋 Minor Observations
🎯 Deployment ConsiderationsThe PR includes proper safeguards for production deployment:
✅ Final AssessmentThis is an excellent implementation that:
Recommendation: APPROVE - This PR demonstrates thorough engineering practices and is ready to merge. Job Run | Branch: abhijitmadhusudan496/si-915-staking-4-bitgojs-v8-staking-builders-83cd |
Summary
Polymesh v8 changed
staking.bondfrombond(controller, value, payee)tobond(value, payee)(the stash is its own controller). The existingBatchStakingBuilderalways passescontrollerand uses v7 metadata, so a v8 new-stake (utility.batchAll([bond, nominate])) encodes the wrong extrinsic.This adds
V8BatchStakingBuilder— buildingbatchAll([bond, nominate])with the 2-arg v8 bond against v8 chain metadata — plus thin v8 metadata wrappers for the staking operations whose call shape is unchanged. The v7 builders are kept untouched as the Flipt rollback path and marked[CLEANUP-V8-OLD].Changes
V8BatchStakingBuilder—bond({ value, payee })(nocontroller) insidebatchAll([bond, nominate]), v8 material.V8BondExtraBuilder,V8UnbondBuilder,V8BatchUnstakingBuilder,V8WithdrawUnbondedBuilder,V8NominateBuilder.iface.ts— newV8BondArgs { value, payee };BondArgskept and marked[CLEANUP-V8-OLD].txnSchema.ts—V8BatchTransactionSchema(bond/batch validation withoutcontroller).getV8*()methods for each new builder;from()now routes v8-encoded staking transactions (which cannot be decoded with v7 material) to the matching v8 builder.[CLEANUP-V8-OLD]comments on the v7 staking builders.Testing
v8BatchStakingBuilder.tsunit tests: v8 material loads (specVersion8000000), controller setter is absent, both-leg validation, decode/validate round-trip (bond hasvalueonly, nocontroller),from()routing, and smoke builds for each wrapper.batchAllmethod hex is asserted byte-for-byte equal to the testnet sandbox tx (block 24829135) built with the same params.BatchStakingBuildertests unchanged and still pass.yarn lint/yarn buildclean. (The pre-existingPolyx:suite failure is an unrelatedBITGOJS_TEST_PASSWORDenv requirement.)